<template>
    <div class="header-panel">
        <!-- <div class="banner">
            <div class="banner-left"></div>
            <img src="../assets/images/header/banner.png" width="1920" height=98>
            <div class="banner-right"></div>
        </div> -->

        <div class="header">
            <div class="left">
                <div id="timeContainer">
                    <span id="clock">
                        <span style="float:left">{{dateTime.time}}</span>
                    </span>
                    <span id="date">{{dateTime.date}} 星期{{dateTime.day}}</span>
                </div>
            </div>

            <div class="center">
                <p>{{$project.title}}</p>
            </div>

            <div class="right">
                <Profile />
            </div>
        </div>
    </div>
</template>

<script>
import moment from "moment";
import Profile from "./profile/index.vue";
export default {
    components: {
        // Scheme, 
        Profile
    },
    data() {
        return {
            dateTime: {
                date: "",
                day: "",
                time: ""
            },
            dayMap: ["日", "一", "二", "三", "四", "五", "六"],
            timer: null,
        };
    },
    mounted() {
        let me = this;
        // 时间
        me.timer = setInterval(() => {
            me.dateTime.date = moment().format("YYYY/M/D");
            me.dateTime.day = this.dayMap[moment().day()];
            me.dateTime.time = moment().format("HH:mm:ss");
        }, 1000);

        me.$nextTick(() => {
            me.onResize();
            //根据窗口的大小变动图表
            window.addEventListener("resize", () => { me.onResize() });
        })
    },
    methods: {
        onResize() {
            let me = this;
            let title = $('.header-title');
            title.css("left", (document.body.clientWidth - title.width()) / 2);
        }
    },
    destroyed() {
        clearInterval(this.timer);
    },
}
</script>

<style lang="scss" scoped>
@import "@/assets/styles/index.scss";

.header-panel {
    width: 100%;
    height: 99px;
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9;

    .banner {
        .banner-left {
            width: calc(50% - 960px);
            height: 71px;
            top: 0;
            left: 0;
            position: absolute;
            z-index: 1;
            // background-color: #051429e6;
            background: url(../assets/images/header/bg.png);
            background-size: 100% 100%;
        }

        .banner-right {
            width: calc(50% - 960px);
            height: 71px;
            top: 0;
            right: 0;
            position: absolute;
            z-index: 1;
            // background-color: #051429e6;
            background: url(../assets/images/header/bg.png);
            background-size: 100% 100%;
        }

        img {
            position: absolute;
            left: calc(50% - 960px);
            z-index: 1;
        }
    }

    .header {
        width: 100%;
        height: 70px;
        top: 0;
        left: 0;
        position: absolute;
        z-index: 9;
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: space-between;
        @include background_color("panel-background-color");
        // background-color: #2a2b2ee7;
        // background: url(../assets/images/header/bg.png);

        .left {
            width: 400px;
            height: 100%;
            text-align: left;
        }

        .center {
            height: 100%;
            width: 560px;

            p {
                margin: 0;
                font-size: 35px;
                padding-top: 10px;
                font-family: SourceHanSansSC-Bold;
                font-weight: bold;
                text-align: center;
                // @include font_color("label-color");
                @include background_linear("label-color", "panel-background-color");
            }
        }

        .right {
            width: 400px;
            height: 100%;
        }
    }

    #timeContainer {
        left: 0px;
        text-align: center;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 150px;
        float: left;
        padding: 0px;
    }

    #date {
        display: block;
        font-size: 10px;
        font-weight: normal;
        line-height: 12px;
        @include font_color("label-color");
    }

    #clock {
        @include font_color("label-color");
        display: block;
        letter-spacing: 2.0px;
        font-size: 1.5rem;
        line-height: 2rem;
    }

}

</style>

